#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2019/12/31 08:29|08:29
# @Author  : yangdingyi
# @File    : 两数之和
# @Software: PyCharm
from typing import List


class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:
        # ss = {}
        # for i, n in enumerate(nums):
        #     if n in ss:
        #         return [i, ss[n]]
        #     ss[target-n] = i
        # return []
        ss = {}
        global ans
        ans = []

        def work(a):
            if a[1] in ss:
                global ans
                ans = [a[0], ss[a[1]]]
                return ans
            ss[target-a[1]] = a[0]
            return False
        any(map(work, enumerate(nums)))

        return ans


solve = Solution()
nums = [2, 7, 8, 10]
target = 9
print(nums, target)
print(solve.twoSum(nums, target))


